package com.bw.controller;

import com.alibaba.fastjson2.JSONObject;
import com.bw.service.FoodService;
import com.mysql.cj.xdevapi.JsonArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class FoodController {

    @Autowired
    FoodService foodService;

    @RequestMapping("/get1")
    public Object get1(){
        List<Map> list = foodService.get1();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");

        JSONObject jsonObject2 = new JSONObject();
        jsonObject.put("data",jsonObject2);

        JsonArray array1 = new JsonArray();
        JsonArray array2 = new JsonArray();

        jsonObject2.put("categories",array1);

        jsonObject2.put("series",array2);
        JSONObject jsonObject3 = new JSONObject();
        jsonObject3.put("name","count");


        return jsonObject;
    }

    @RequestMapping("/get2")
    public Object get2(){
        List<Map> list = foodService.get2();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");

        JSONObject jsonObject2 = new JSONObject();
        jsonObject.put("data",jsonObject2);

        JsonArray array1 = new JsonArray();
        JsonArray array2 = new JsonArray();

        jsonObject2.put("categories",array1);

        jsonObject2.put("series",array2);
        JSONObject jsonObject3 = new JSONObject();
        jsonObject3.put("name","count");


        return jsonObject;
    }
}
